package com.team.olympic.pojo;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class Response<T> {
    private Integer code; // 业务的状态码 0-成功 1-失败
    private String msg;
    private T data;

    public static <E> Response<E> success(String msg, E data) {
        return new Response<>(200, msg, data);
    }

    public static <E> Response<E> success(E data) {
        return new Response<>(200, "操作成功", data);
    }

    public static Response<?> success(String msg) {
        return new Response<>(200, "操作成功", null);
    }

    public static Response<?> success() {
        return new Response<>(200, "操作成功", null);
    }

    public static Response<?> error(String msg) {
        return new Response<>(500, msg, null);
    }

    public static Response<?> error() {
        return new Response<>(500, "操作失败", null);
    }
}